package com.tm.d12_generics_method;

import com.sun.org.apache.bcel.internal.generic.NEW;
import com.tm.d10_generics_class.Dog;
import com.tm.d21_interface.B;
import com.tm.d21_interface.C;

import java.util.ArrayList;

/**
 * 2024/5/22 Cjj 泛型方法的定义和使用 17:56
 */
public class Test {
    public static void main(String[] args) {
      String rs=  test("java");
        System.out.println(rs);


        Dog d=  test(new Dog());
        System.out.println(d);

        //需求：所有汽车可以一起参加比赛
        ArrayList<Car> cars = new ArrayList<>();
         cars.add(new BMW());
         cars.add(new BENZ());
         go(cars);


        ArrayList<BMW> bmws = new ArrayList<>();
        bmws.add(new BMW());
        bmws.add(new BMW());
         go(bmws);

        ArrayList<BENZ> benzs = new ArrayList<>();
        benzs.add(new BENZ());
        benzs.add(new BENZ());
         go(benzs);

    /*    ArrayList<Dog> dogs = new ArrayList<>();
       dogs.add(new Dog());
       dogs.add(new Dog());
       go(dogs);*/


    }

    public static void go(ArrayList<? extends Car >cars ){

    }

/*   public static <T> void go(ArrayList<T> cars){

   }*/
    //泛型方法
    public static <T> T test(T t){
          return t;
    }
}
